package com.example.egmvc1.dto;

import com.example.egmvc1.demos.web.pojo.Staff;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
public class StaffEmp {
    @RequestMapping("/emp/insert")
    @ResponseBody
    public String insertStaff(Staff staff) {
        String name = staff.getName();
        Double salary = staff.getSalary();
        String job = staff.getJob();
        return name + "-" + salary + "-" + job;
    }

    @RequestMapping("/emp/select")
    @ResponseBody
    public String selectStaff() {
        return "恭喜,查询成功";
    }

    @RequestMapping("emp/update")
    @ResponseBody
    public String updateStaff(HttpServletRequest request) {
        String name = request.getParameter("name");
        String salary = request.getParameter("salary");
        String job = request.getParameter("job");
        return name + "-" + salary + "-" + job;
    }

    @RequestMapping("emp/delete")
    @ResponseBody
    public String deleteStaff(String id) {
        String  delete = "删除成功";
        return id + delete;
    }
}
